<template>
   <div class="nav-bar" :class="{isApp: $route.query.isApp}">
     <div class="bar" :class="{fixed: fixed}">
      <span class="icon-back" v-if="isBack" @click="backPage"></span>
      <div class="nav-title">{{title}}</div>
      <div class="right-pos">
        <slot/>
      </div>
     </div>
   </div>
</template>
<script>
export default {
  name: 'NavBar',
  data() {
    return {
    };
  },
  props: {
    title: [String],
    backRoute: {
      type: Function
    },
    isBack: {
      type: Boolean,
      default: true
    },
    fixed: {
      type: String,
      default: 'fixed'
    }
  },
  mounted() {
  },
  methods: {
    backPage() {
      // 自定义返回键
      if (this.backRoute) {
        this.backRoute();
      } else {
        this.$router.go(-1);
      }
    }
  }
};
</script>
<style lang="scss" scoped>
.right-pos{
  position: absolute;
  right: 30px;
  top:20px;
  font-size: 28px;
  color: #666;
}

.nav-bar{
  height: 88px;
  .bar.fixed{
    position: fixed;
    top:0;
    left:0;
    right: 0;
    z-index: 999;
  }
  .bar{
    height: 88px;
    background-color: #fff;
  }
  .icon-back{
    width:22px;
    height: 40px;
    padding: .2rem;
    position: absolute;
    left:25px;
    top:8px;
    background-image: url('../assets/images/icon-arrow-back.png');
    background-position: center center;
    background-repeat: no-repeat;
    background-size: 22px 40px;
  }
  .nav-title{
    text-align: center;
    color: #252733;
    font-size: 36px;
    line-height: 88px;
    border-bottom: 1px solid #F9F7F7;
  }
}
.isApp.nav-bar{
  background-color: #fff;
  height: 138px;
  .icon-back{
    top:43px;
  }
  .bar.fixed{
    top:0;
    padding-top: 50px;
    .icon-back{
      top:60px;
    }
  }
  .right-pos{
    top:70px;
  }
}
</style>
